package com.ychong.controller;


import com.ychong.dao.CommonResult;
import com.ychong.dao.ElecTypeDto;
import com.ychong.dao.FileDto;
import com.ychong.service.ElecTypeService;
import com.ychong.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/elecType")
public class ElecTypeController {
    @Autowired
    ElecTypeService elecTypeService;
    @GetMapping(value = "/addElecType")
    public CommonResult addElecType(@RequestBody ElecTypeDto item){
        int index = elecTypeService.addElecType(item);
        CommonResult<List<FileDto>> commonResult = new CommonResult<List<FileDto>>(null);
        if (index>=0){
            commonResult.setSuccess(true);
        }else {
            commonResult.setSuccess(false);
            commonResult.setErrorMsg("添加失败");
        }

        return commonResult;
    }
}
